package mo.leetcode_top;

public class L551 {

    public boolean checkRecord(String s) {

        int absentCount = 0;
        int continueLateCount = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                absentCount++;
                if (absentCount >= 2) {
                    return false;
                }
            }

            else if (s.charAt(i) == 'L') {
                if (i > 0 && s.charAt(i-1) != 'L') {
                    continueLateCount = 0;
                }
                continueLateCount++;
                if (continueLateCount >= 3) {
                    return false;
                }
            }
        }

        return true;

    }

}
